// components/rate/rate.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    value: {type: Number, value: 3.9},
    showText: {type: Boolean, value: false},
  },

  /**
   * 组件的初始数据
   */
  data: {
    rate_num: [0,0,0,0,0],
  },

  ready() {
    let { rate_num, value } = this.data;
    value > 5 && (value = 5);
    value < 0 && (value = 0);
    let arr = value.toString().split('.');
    let i = 0;
    while(i < arr[0]) {
      rate_num[i] = 1;
      i++;
    }

    arr[1] && (rate_num[arr[0]] = +`0.${arr[1]}`);
    this.setData({
      rate_num, value
    })
  },

  /**
   * 组件的方法列表
   */
  methods: {
    touchmove(e) {
      console.log(e.touches[0].clientX);
    },
  }
})
